package com.iflytek.esb.function;

import java.util.Map;

import com.iflytek.esb.domain.Message;
import com.iflytek.esb.exceptions.RetryableException;
import com.iflytek.esb.util.Consts;
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;

public abstract class MessageFunction implements com.opensymphony.workflow.FunctionProvider {
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException, RetryableException {
		
		Message message = (Message)transientVars.get(Consts.VAR_NAME_MESSAGE);
		
		process(message, args, ps);
		
	}
	
	protected abstract void process(Message message, final Map<String, String> args, PropertySet ps) 
			throws WorkflowException;

}
